#ifndef RIVIATOOLMGR_H
#define RIVIATOOLMGR_H

#include <QMutex>
#include <QHash>
#include "ToolState.h"

class RIVIAToolBase;

class RIVIAToolMgr
{
public:
    static RIVIAToolMgr* getInstance();
    static void freeInstance();

private:
    RIVIAToolMgr();
    virtual ~RIVIAToolMgr();

private:
    static RIVIAToolMgr* m_pInstance;
    static QMutex m_lockMutex;

public:
    void addTool(const QString& strToolName, RIVIAToolBase* pTool);
    RIVIAToolBase* getTool(const QString& strToolName);

    ToolState getEnCurTool() const;
    void setEnCurTool(const ToolState &enCurTool);

private:
    QHash<QString, RIVIAToolBase*>* m_pToolsHash;

    ToolState m_enCurTool;

};

#define RIVIA_REGISTER_TOOL(tool, ToolName)  \
class tool##Factory                                      \
{                                                                                                     \
public:                                                                                               \
    tool##Factory(){RIVIAToolMgr::getInstance()->addTool(#ToolName, new tool());}     \
}; \
static tool##Factory g_##tool##strategyInstance;

#endif // RIVIATOOLMGR_H
